%store -r gp_train
%store -r gp_test
%store -r Y_train
import gpfeatures
import seaborn as sns
from sklearn import tree
import graphviz
from IPython import display
import matplotlib.pyplot as plt
import shap
ex=gpfeatures.ExtraTreesClassifier(n_estimators=241,max_features=31,max_depth=4,min_samples_split=6,min_samples_leaf =2)
ex.fit(gp_train,Y_train)
data_for_prediction = gp_test.iloc[:] # use 1 row of data here. Could use multiple rows if desired
data_for_prediction_array = data_for_prediction.values.reshape(1, -1)
explainer = shap.TreeExplainer(ex)
shap_values = explainer.shap_values(data_for_prediction)
shap.initjs()
shap.force_plot(explainer.expected_value[1], shap_values[1], data_for_prediction)
import catboost as cb
cat= cb.CatBoostClassifier(depth=5, learning_rate=0.03, loss_function='Logloss',leaf_estimation_method='Gradient',iterations=111,
bagging_temperature=2,od_type='Iter',od_wait=100,verbose=False,eval_metric='AUC')
cat.fit(gp_train,Y_train)
data_for_prediction = gp_test.iloc[:] # use 1 row of data here. Could use multiple rows if desired
data_for_prediction_array = data_for_prediction.values.reshape(1, -1)
explainer = shap.TreeExplainer(cat)
shap_values = explainer.shap_values(data_for_prediction)
shap.initjs()
shap.force_plot(explainer.expected_value, shap_values, data_for_prediction)